package com.wenhao.sf;

import java.util.*;

/**
 * @author Wenhao Tong
 * @create 2021-08-30 19:32
 */
public class Main2 {
    public static void main(String[] args) {
        ThreadLocal<String> stringThreadLocal = new ThreadLocal<>();
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int q = scanner.nextInt();
        int[][] map = new int[n][n];
        for (int i = 0;i < m;i++) {
            int j = scanner.nextInt() - 1;
            int k = scanner.nextInt() - 1;
            map[j][k] = scanner.nextInt();
            map[k][j] = map[j][k];
        }
        for (int i = 0;i < q;i++) {
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            Queue<Integer> queue = new LinkedList<>();
            queue.add(x - 1);
            int max = 0;
            int[] visited = new int[n];
            while (queue.size() > 0) {
                Integer j = queue.poll();
                visited[j] = 1;
                if (j == y - 1) {
                    break;
                }
                for (int k = 0;k < n;k++) {
                    if (map[j][k] != 0 && visited[k] == 0) {
                        queue.add(k);
                        max = Math.max(map[j][k],max);
                    }
                }
            }
            System.out.println(max);
        }
    }
}
